package com.efast.dmom.mes.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.Param;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.ParamService;

@Controller
@RequestMapping("/Param")
public class ParamController {
	@Autowired
	private ParamService paramService;
	
	@RequestMapping(value = "/operateToBasicByParam")
	public @ResponseBody ResultBean operateToBasicByParam(@RequestBody Param  param) {
		if (param.getModificationFlag() == IModificationFlags.NEW) {
			return paramService.save(param);
			// Judge update
		} else if (param.getModificationFlag() == IModificationFlags.MODIFIED) {
			return paramService.update(param);
			// Judge to delete
		} else if (param.getModificationFlag() == IModificationFlags.DELETED) {
			return paramService.delete(param);
		}
		return null;
		
	}
}
